int g(struct TreeNode* root, int i)
{
    if (root == NULL)
    {
        return 0;
    }
    if (root->left == root->right)
    {
        if (i == 1)
            return root->val;
        else
            return 0;
    }
    return g(root->left, 1) + g(root->right, 0);
}

int sumOfLeftLeaves(struct TreeNode* root) {
    if (root == NULL)
    {
        return 0;
    }
    return g(root->left, 1) + g(root->right, 0);
}